<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - getrf.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2010  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_LAPACk_GETRF_Hh_
<font color='#0000FF'>#define</font> DLIB_LAPACk_GETRF_Hh_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='fortran_id.h.html'>fortran_id.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../matrix.h.html'>../matrix.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>
    <font color='#0000FF'>namespace</font> lapack
    <b>{</b>
        <font color='#0000FF'>namespace</font> binding
        <b>{</b>
            <font color='#0000FF'>extern</font> "<font color='#CC0000'>C</font>"
            <b>{</b>
                <font color='#0000FF'><u>void</u></font> <b><a name='DLIB_FORTRAN_ID'></a>DLIB_FORTRAN_ID</b><font face='Lucida Console'>(</font>dgetrf<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>integer<font color='#5555FF'>*</font> m, integer <font color='#5555FF'>*</font>n, <font color='#0000FF'><u>double</u></font> <font color='#5555FF'>*</font>a, 
                                             integer<font color='#5555FF'>*</font> lda, integer <font color='#5555FF'>*</font>ipiv, integer <font color='#5555FF'>*</font>info<font face='Lucida Console'>)</font>;

                <font color='#0000FF'><u>void</u></font> <b><a name='DLIB_FORTRAN_ID'></a>DLIB_FORTRAN_ID</b><font face='Lucida Console'>(</font>sgetrf<font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>integer<font color='#5555FF'>*</font> m, integer <font color='#5555FF'>*</font>n, <font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font>a, 
                                             integer<font color='#5555FF'>*</font> lda, integer <font color='#5555FF'>*</font>ipiv, integer <font color='#5555FF'>*</font>info<font face='Lucida Console'>)</font>;

            <b>}</b>

            <font color='#0000FF'>inline</font> <font color='#0000FF'><u>int</u></font> <b><a name='getrf'></a>getrf</b> <font face='Lucida Console'>(</font>integer m, integer n, <font color='#0000FF'><u>double</u></font> <font color='#5555FF'>*</font>a, 
                              integer lda, integer <font color='#5555FF'>*</font>ipiv<font face='Lucida Console'>)</font>
            <b>{</b>
                integer info <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#BB00BB'>DLIB_FORTRAN_ID</font><font face='Lucida Console'>(</font>dgetrf<font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>m, <font color='#5555FF'>&amp;</font>n, a, <font color='#5555FF'>&amp;</font>lda, ipiv, <font color='#5555FF'>&amp;</font>info<font face='Lucida Console'>)</font>;
                <font color='#0000FF'>return</font> info;
            <b>}</b>

            <font color='#0000FF'>inline</font> <font color='#0000FF'><u>int</u></font> <b><a name='getrf'></a>getrf</b> <font face='Lucida Console'>(</font>integer m, integer n, <font color='#0000FF'><u>float</u></font> <font color='#5555FF'>*</font>a, 
                              integer lda, integer <font color='#5555FF'>*</font>ipiv<font face='Lucida Console'>)</font>
            <b>{</b>
                integer info <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                <font color='#BB00BB'>DLIB_FORTRAN_ID</font><font face='Lucida Console'>(</font>sgetrf<font face='Lucida Console'>)</font><font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>m, <font color='#5555FF'>&amp;</font>n, a, <font color='#5555FF'>&amp;</font>lda, ipiv, <font color='#5555FF'>&amp;</font>info<font face='Lucida Console'>)</font>;
                <font color='#0000FF'>return</font> info;
            <b>}</b>


        <b>}</b>

    <font color='#009900'>// ------------------------------------------------------------------------------------
</font>

<font color='#009900'>/*  -- LAPACK routine (version 3.1) -- */</font>
<font color='#009900'>/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */</font>
<font color='#009900'>/*     November 2006 */</font>

<font color='#009900'>/*     .. Scalar Arguments .. */</font>
<font color='#009900'>/*     .. */</font>
<font color='#009900'>/*     .. Array Arguments .. */</font>
<font color='#009900'>/*     .. */</font>

<font color='#009900'>/*  Purpose */</font>
<font color='#009900'>/*  ======= */</font>

<font color='#009900'>/*  DGETRF computes an LU factorization of a general M-by-N matrix A */</font>
<font color='#009900'>/*  using partial pivoting with row interchanges. */</font>

<font color='#009900'>/*  The factorization has the form */</font>
<font color='#009900'>/*     A = P * L * U */</font>
<font color='#009900'>/*  where P is a permutation matrix, L is lower triangular with unit */</font>
<font color='#009900'>/*  diagonal elements (lower trapezoidal if m &gt; n), and U is upper */</font>
<font color='#009900'>/*  triangular (upper trapezoidal if m &lt; n). */</font>

<font color='#009900'>/*  This is the right-looking Level 3 BLAS version of the algorithm. */</font>

<font color='#009900'>/*  Arguments */</font>
<font color='#009900'>/*  ========= */</font>

<font color='#009900'>/*  M       (input) INTEGER */</font>
<font color='#009900'>/*          The number of rows of the matrix A.  M &gt;= 0. */</font>

<font color='#009900'>/*  N       (input) INTEGER */</font>
<font color='#009900'>/*          The number of columns of the matrix A.  N &gt;= 0. */</font>

<font color='#009900'>/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */</font>
<font color='#009900'>/*          On entry, the M-by-N matrix to be factored. */</font>
<font color='#009900'>/*          On exit, the factors L and U from the factorization */</font>
<font color='#009900'>/*          A = P*L*U; the unit diagonal elements of L are not stored. */</font>

<font color='#009900'>/*  LDA     (input) INTEGER */</font>
<font color='#009900'>/*          The leading dimension of the array A.  LDA &gt;= max(1,M). */</font>

<font color='#009900'>/*  IPIV    (output) INTEGER array, dimension (min(M,N)) */</font>
<font color='#009900'>/*          The pivot indices; for 1 &lt;= i &lt;= min(M,N), row i of the */</font>
<font color='#009900'>/*          matrix was interchanged with row IPIV(i). */</font>

<font color='#009900'>/*  INFO    (output) INTEGER */</font>
<font color='#009900'>/*          = 0:  successful exit */</font>
<font color='#009900'>/*          &lt; 0:  if INFO = -i, the i-th argument had an illegal value */</font>
<font color='#009900'>/*          &gt; 0:  if INFO = i, U(i,i) is exactly zero. The factorization */</font>
<font color='#009900'>/*                has been completed, but the factor U is exactly */</font>
<font color='#009900'>/*                singular, and division by zero will occur if it is used */</font>
<font color='#009900'>/*                to solve a system of equations. */</font>


    <font color='#009900'>// ------------------------------------------------------------------------------------
</font>
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
            <font color='#0000FF'>typename</font> T, 
            <font color='#0000FF'><u>long</u></font> NR1, <font color='#0000FF'><u>long</u></font> NR2,
            <font color='#0000FF'><u>long</u></font> NC1, <font color='#0000FF'><u>long</u></font> NC2, 
            <font color='#0000FF'>typename</font> MM,
            <font color='#0000FF'>typename</font> layout
            <font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>int</u></font> <b><a name='getrf'></a>getrf</b> <font face='Lucida Console'>(</font>
            matrix<font color='#5555FF'>&lt;</font>T,NR1,NC1,MM,column_major_layout<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> a,
            matrix<font color='#5555FF'>&lt;</font>integer,NR2,NC2,MM,layout<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> ipiv 
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> m <font color='#5555FF'>=</font> a.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> n <font color='#5555FF'>=</font> a.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            ipiv.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font>m,n<font face='Lucida Console'>)</font>, <font color='#979000'>1</font><font face='Lucida Console'>)</font>;

            <font color='#009900'>// compute the actual decomposition 
</font>            <font color='#0000FF'>return</font> binding::<font color='#BB00BB'>getrf</font><font face='Lucida Console'>(</font>m, n, <font color='#5555FF'>&amp;</font><font color='#BB00BB'>a</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>, a.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#5555FF'>&amp;</font><font color='#BB00BB'>ipiv</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

    <font color='#009900'>// ------------------------------------------------------------------------------------
</font>
    <b>}</b>

<b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_LAPACk_GETRF_Hh_
</font>

</pre></body></html>